#include <SDL.h>
#include <SDL_mixer.h>
#include <assert.h>
#include "scr_sound.h"

SCRSound::SCRSound(const std::string& Filename)
	: SCRResource()
	, m_pSound(NULL)
{
	m_pSound = Mix_LoadWAV(Filename.c_str());
	if (m_pSound)
	{
		m_Filename = Filename;
		m_IsValid = true;
	}
}

SCRSound::~SCRSound()
{
	if (m_pSound)
	{
		Mix_FreeChunk(m_pSound);
	}
}

void SCRSound::Play()
{
	assert(m_pSound);

	Mix_PlayChannel(-1, m_pSound, 0);
}

